/**
 * @description vue3响应式原理
 */

// 判断是否为object
function isObject(target) {
    return target && typeof target === 'object';
}
// 副作用 响应式
function watchEffect(callback){
    if(typeof callback === 'function'){

    }
}
// 数据劫持
function reactive(target) {
    if(!isObject(target)){
        return target;
    }
    const proxy = new Proxy(target,proxyHandler);
    return proxy;
}
const proxyHandler = {
    get(target,key,receiver){
       const res = Reflect.get(target,key,receiver);
       console.log('获取');
       return res;
    },
    set(target,key,value,receiver){
        if(target[key]!==value){
            const res = Reflect.set(target,key,value,receiver);
            console.log('设置');
            return res;
        }
    },
    deleteProperty(target,key){
        const res = Reflect.deleteProperty(target,key);
        console.log('删除');
        return res;
    }
}
let obj = {name:'aa'};
let res = reactive(obj)